using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_SubPage {
		#region Fields
		private int sub_pgID;
		private int main_pgID;
		private string sub_pgName;
		private string sub_pgTitle;
		private int sub_pgPriority;
		private DateTime sub_dateModified = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private int languageID;
		private string cSSName;
		private string uRL;
		private int itemID;
		private int eventID;
		private int checkedStatus;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_SubPage class.
		/// </summary>
		public TF_SubPage() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_SubPage class.
		/// </summary>
		public TF_SubPage(int main_pgID, string sub_pgName, string sub_pgTitle, int sub_pgPriority, DateTime sub_dateModified, int languageID, string cSSName, string uRL, int itemID, int eventID, int checkedStatus) {
			this.main_pgID = main_pgID;
			this.sub_pgName = sub_pgName;
			this.sub_pgTitle = sub_pgTitle;
			this.sub_pgPriority = sub_pgPriority;
			this.sub_dateModified = sub_dateModified;
			this.languageID = languageID;
			this.cSSName = cSSName;
			this.uRL = uRL;
			this.itemID = itemID;
			this.eventID = eventID;
			this.checkedStatus = checkedStatus;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_SubPage class.
		/// </summary>
		public TF_SubPage(int sub_pgID, int main_pgID, string sub_pgName, string sub_pgTitle, int sub_pgPriority, DateTime sub_dateModified, int languageID, string cSSName, string uRL, int itemID, int eventID, int checkedStatus) {
			this.sub_pgID = sub_pgID;
			this.main_pgID = main_pgID;
			this.sub_pgName = sub_pgName;
			this.sub_pgTitle = sub_pgTitle;
			this.sub_pgPriority = sub_pgPriority;
			this.sub_dateModified = sub_dateModified;
			this.languageID = languageID;
			this.cSSName = cSSName;
			this.uRL = uRL;
			this.itemID = itemID;
			this.eventID = eventID;
			this.checkedStatus = checkedStatus;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the Sub_pgID value.
		/// </summary>
		public int Sub_pgID {
			get { return sub_pgID; }
			set { sub_pgID = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_pgID value.
		/// </summary>
		public int Main_pgID {
			get { return main_pgID; }
			set { main_pgID = value; }
		}
		
		/// <summary>
		/// Gets or sets the Sub_pgName value.
		/// </summary>
		public string Sub_pgName {
			get { return sub_pgName; }
			set { sub_pgName = value; }
		}
		
		/// <summary>
		/// Gets or sets the Sub_pgTitle value.
		/// </summary>
		public string Sub_pgTitle {
			get { return sub_pgTitle; }
			set { sub_pgTitle = value; }
		}
		
		/// <summary>
		/// Gets or sets the Sub_pgPriority value.
		/// </summary>
		public int Sub_pgPriority {
			get { return sub_pgPriority; }
			set { sub_pgPriority = value; }
		}
		
		/// <summary>
		/// Gets or sets the Sub_dateModified value.
		/// </summary>
		public DateTime Sub_dateModified {
			get { return sub_dateModified; }
			set { sub_dateModified = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanguageID value.
		/// </summary>
		public int LanguageID {
			get { return languageID; }
			set { languageID = value; }
		}
		
		/// <summary>
		/// Gets or sets the CSSName value.
		/// </summary>
		public string CSSName {
			get { return cSSName; }
			set { cSSName = value; }
		}
		
		/// <summary>
		/// Gets or sets the URL value.
		/// </summary>
		public string URL {
			get { return uRL; }
			set { uRL = value; }
		}
		
		/// <summary>
		/// Gets or sets the ItemID value.
		/// </summary>
		public int ItemID {
			get { return itemID; }
			set { itemID = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventID value.
		/// </summary>
		public int EventID {
			get { return eventID; }
			set { eventID = value; }
		}
		
		/// <summary>
		/// Gets or sets the CheckedStatus value.
		/// </summary>
		public int CheckedStatus {
			get { return checkedStatus; }
			set { checkedStatus = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_SubPages table.
		/// </summary>
		public void Insert() {
			sub_pgID = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_SubPagesInsert", main_pgID, sub_pgName, sub_pgTitle, sub_pgPriority, sub_dateModified, languageID, cSSName, uRL, itemID, eventID, checkedStatus));
		}
		
		/// <summary>
		/// Updates a record in the TF_SubPages table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_SubPagesUpdate", sub_pgID, main_pgID, sub_pgName, sub_pgTitle, sub_pgPriority, sub_dateModified, languageID, cSSName, uRL, itemID, eventID, checkedStatus);
		}
		
		/// <summary>
		/// Deletes a record from the TF_SubPages table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_SubPagesDelete", sub_pgID);
		}
		
		/// <summary>
		/// Selects a single record from the TF_SubPages table.
		/// </summary>
		public static TF_SubPage Select(int sub_pgID) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_SubPagesSelect", sub_pgID)) {
				if (dataReader.Read()) {
					return MakeTF_SubPage(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_SubPages table.
		/// </summary>
		public static List<TF_SubPage> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_SubPagesSelectAll")) {
				List<TF_SubPage> tF_SubPageList = new List<TF_SubPage>();
				while (dataReader.Read()) {
					TF_SubPage tF_SubPage = MakeTF_SubPage(dataReader);
					tF_SubPageList.Add(tF_SubPage);
				}
				return tF_SubPageList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_SubPages class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_SubPage MakeTF_SubPage(SqlDataReader dataReader) {
			TF_SubPage tF_SubPage = new TF_SubPage();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_SubPage.Sub_pgID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_SubPage.Main_pgID = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_SubPage.Sub_pgName = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_SubPage.Sub_pgTitle = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_SubPage.Sub_pgPriority = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_SubPage.Sub_dateModified = dataReader.GetDateTime(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_SubPage.LanguageID = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_SubPage.CSSName = dataReader.GetString(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_SubPage.URL = dataReader.GetString(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_SubPage.ItemID = dataReader.GetInt32(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_SubPage.EventID = dataReader.GetInt32(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_SubPage.CheckedStatus = dataReader.GetInt32(11);
			}

			return tF_SubPage;
		}
		#endregion
	}
}
